/**
 * 表单组件
 * 根据field策略生成相应的Ext表单元素
 * 
 */
$import("config");

config.FormComponent = function(fieldInfo, cfg) {
	var component = {};
	var qs = fieldInfo.queryStrategy;
	var ef = Ext.form;
	if (! cfg) cfg = {};
	// 配置
	if (! cfg.fieldLabel)
		cfg.fieldLabel = fieldInfo.alias; // 字段别名
	
	if (qs == 'STRING_EXACT' || qs == 'STRING_LIKE' || qs == 'STRING_MULTI') {
		component = new ef.TextField(cfg);
	} else if (qs == 'DATE_EXACT') {
		cfg.format = 'Y-m-d';
		component = new ef.DateField(cfg);
	} else if (qs == 'DATE_BETWEEN') {
		component = [];
		cfg.format = 'Y-m-d';
		component[0] = new ef.DateField(cfg);
		cfg.fieldLabel = '至';
		component[1] = new ef.DateField(cfg);
	} else if (qs == 'INT_EXACT' || qs == 'LONG_EXACT' || qs == 'INT_MULTI') {
		component = new ef.NumberField(cfg);
	}
	// 建立字段配置的引用
	if (qs.indexOf('_BETWEEN') == -1)
		component.fieldInfo = fieldInfo;
	else {
		component[0].fieldInfo = fieldInfo;
		component[1].fieldInfo = fieldInfo;
	}
		
	return component;
};


